import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-01-11
 * Time: 21:15
 */
class Equation{
    String dividend;// 被除数
    String divisor;// 除数
    public Equation(){}
    public Equation(String dividend, String divisor){
        this.dividend=dividend;
        this.divisor=divisor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Equation equation = (Equation) o;
        return Objects.equals(dividend, equation.dividend) && Objects.equals(divisor, equation.divisor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dividend, divisor);
    }
}
public class Solution {
    public double[] calcEquation(List<List<String>> equations, double[] values, List<List<String>> queries) {
        Map<Equation, Double> map=new HashMap<>();
        int size=equations.size();
        for (int i = 0; i < size; i++) {
            String dividend=equations.get(i).get(0);
            String divisor=equations.get(i).get(1);
            map.put(new Equation(dividend, divisor), values[i]);
        }
        int count=queries.size();
        double[] result=new double[count];
        for (int i = 0; i < count; i++) {
            List<String> list=queries.get(i);
            Equation temp=new Equation(list.get(0), list.get(1));
            double ans=map.getOrDefault(temp, -1.0);
            result[i]=ans;
        }
        return result;
    }
}

